<?php
namespace Admin\Models\sys;
use Admin\Models\BaseModel;
class XhsysUserTch extends BaseModel
{

    /**
     *
     * @var integer
     * @Primary
     * @Identity
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iTchId;

    public $bImportant;

    public $sSubjects;

    /**
     *
     * @var string
     * @Column(type="string", length=50, nullable=true)
     */
    public $sAdminClass;

    /**
     *
     * @var string
     * @Column(type="string", length=50, nullable=true)
     */
    public $sEBagClass;

    public $iProficiency;
    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iUserId;


    public $iSubject;


    public $iCurGrade;
    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sDuty;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $mEvaluate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bExcellent;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bMine;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * 教师类型
     * @var integer
     *  @Column(type="integer", length=11, nullable=true)
     * create by xjq 20180508
     */
    public $iType;

    /**
     * 是否考核日志
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     * create by dale 20180815
     */
    public $bStatsLog;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $sAuthCode;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bAuthUseful;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHSys_UserTch';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysUserTch[]|XhsysUserTch
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhsysUserTch
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * 获取教师基本信息
     *
     * @param $userId
     * @return array
     *
     * create by sqb 20190108
     */
    public static function getTchInfoByUserId($userId)
    {
        $data = self::findFirst([
            'conditions' => 'bDelete = 0 AND iUserId = :userId:',
            'bind' => ['userId' => $userId]
        ]);

        if ($data) {
            return $data->toArray();
        }

        return [];
    }
}
